function ajaxPost(b, e, f, c, a) {
    var d = null;
    $.ajax({
        url: b,
        type: "POST",
        data: e,
        async: c == undefined ? true: c,
        dataType: a != null ? a: "json",
        complete: function(g) {
            if (a == null || a == "json") {
                d = $.parseJSON(g.responseText);
                if (d != null && d.error == 1 && (d.msg == "BAD REQUEST" || d.msg == "TIMEOUT")) {
                    showTimeoutTips();
                    return
                } else {
                    if (f != null) {
                        f(d)
                    }
                }
            } else {
                f(g)
            }
        }
    });
    return d
}
function syncAjaxPost(a, b, c) {
    return ajaxPost(a, b, c, false)
}
function tips_success(b, a) {
    tips(b, "success", a || 3000)
}
function tips_error(b, a) {
    tips(b, "error", a || 3000)
}
function tips(f, e, a, c) {
    var d = e == "success" ? "done02": "error02";
    var b = {
        id: "alertDlg",
        width: 300,
        fixed: true,
        title: "提示信息",
        content: '<div class="tips-laryer-contbg"><div class="tips-txt"><p class="' + d + '"><span>' + f + "</span></p></div></div>",
        window: "top"
    };
    if (a != null && typeof(a) == "number") {
        b.time = a
    } else {
        if (a != null && typeof(a) == "boolean") {
            b.ok = function(g) {
                return a
            }
        } else {
            b.ok = function(g) {
                return a && a.call(this, g)
            }
        }
    }
    if (c != null && typeof(c) == "number") {
        b.zIndex = c
    }
    b.okValue = "确定";
    art.dialog(b)
}
function tipsNoStyle(f, e, a, c) {
    var d = e == "success" ? "done02": "error02";
    var b = {
        id: "alertDlg",
        width: 300,
        fixed: true,
        title: "提示信息",
        content: f,
        window: "top"
    };
    if (a != null && typeof(a) == "number") {
        b.time = a
    } else {
        if (a != null && typeof(a) == "boolean") {
            b.ok = function(g) {
                return a
            }
        } else {
            b.ok = function(g) {
                return a && a.call(this, g)
            }
        }
    }
    if (c != null && typeof(c) == "number") {
        b.zIndex = c
    }
    b.okValue = "确定";
    art.dialog(b)
}
function showNoSurvey() {
    tipsCallBack("当前问卷已删除", "success", 
    function() {
        location.href = ctx + "/survey"
    })
}
function tipsCallBack(d, c, e) {
    var b = c == "success" ? "done02": "error02";
    var a = {
        id: "alertDlg",
        width: 300,
        fixed: true,
        title: "提示信息",
        content: '<div class="tips-laryer-contbg"><div class="tips-txt"><p class="' + b + '"><span>' + d + "</span></p></div></div>",
        window: "top",
        esc: false
    };
    if (e != null && typeof(e) == "function") {
        a.ok = e;
        a.beforeunload = e
    }
    a.okValue = "确定";
    art.dialog(a)
}
function artconfirm(f, h, g, e, c, a, d) {
    var b = {
        id: "confirmDlg" + (a ? new Date().getTime() : ""),
        width: 300,
        fixed: true,
        window: "top",
        title: "提示信息",
        content: '<div class="tips-laryer-contbg"><div class="tips-txt"><p class="error02">' + f + "</p></div></div>",
        ok: function(i) {
            return h.call(this, i)
        },
        cancel: function(i) {
            return g && g.call(this, i)
        }
    };
    b.okValue = e || "确定";
    b.cancelValue = c || "取消";
    if (d != null && typeof(d) == "number") {
        b.zIndex = d
    }
    return art.dialog(b)
}
function artconfirmNoStyle(f, h, g, e, c, a, d) {
    var b = {
        id: "confirmDlg" + (a ? new Date().getTime() : ""),
        width: 300,
        fixed: true,
        window: "top",
        title: "提示信息",
        content: f,
        ok: function(i) {
            return h.call(this, i)
        },
        cancel: function(i) {
            return g && g.call(this, i)
        }
    };
    b.okValue = e || "确定";
    b.cancelValue = c || "取消";
    if (d != null && typeof(d) == "number") {
        b.zIndex = d
    }
    return art.dialog(b)
}
function debug(a) {
    if (window.console && window.console.debug) {
        window.console.debug("obj: " + a)
    }
}
function getEmptyDiv(a, b) {
    return $("<div/>", {
        "class": a,
        id: b
    })
}
function getRandom(a) {
    return a.sort(function() {
        return Math.random() - Math.random()
    })
}
function hideDIV(a) {
    $("#" + a).hide()
}
function showDIV(a) {
    $("#" + a).show()
}
function disableButtonJQuery(d, a, c) {
    $("#" + d).data("click", a);
    $("#" + d).unbind("click");
    var b = c || 3000;
    if (b > 0) {
        setTimeout(function() {
            enableButtonJQuery(d)
        },
        3000)
    }
}
function enableButtonJQuery(a) {
    $("#" + a).bind("click", $("#" + a).data("click"))
}
function disableButton(b, c) {
    b.disabled = true;
    if (b.onclick) {
        $(b).data("click", b.onclick);
        b.onclick = null
    }
    var a = c || 3000;
    if (a > 0) {
        setTimeout(function() {
            enableButton(b)
        },
        3000)
    }
}
function enableButton(a) {
    a.disabled = false;
    if ($(a).data("click")) {
        a.onclick = $(a).data("click")
    }
}
function getStringLength(d) {
    var a = d.length;
    var b = 0;
    for (var c = 0; c < a; c++) {
        if (d.charCodeAt(c) < 27 || d.charCodeAt(c) > 126) {
            b += 2
        } else {
            b++
        }
    }
    return b
}
function getStringByByte(d, c) {
    var f = 0;
    var a = d.length;
    var b = 0;
    var e = "";
    while (f <= c && b <= a) {
        if (d.charCodeAt(b) > 255) {
            f += 2
        } else {
            f += 1
        }
        if (f <= c) {
            e += d.substring(b, b + 1)
        }
        b++
    }
    return e
}
function checkNum(b) {
    var a = /^\d+(\.\d+)?$/;
    return a.test(b)
}
function resetCheckbox(a) {
    if (a.is(":checked")) {
        a.attr("checked", false)
    } else {
        a.attr("checked", true)
    }
}
function isNotEmpty(a) {
    if (a != undefined && a != null && a != "") {
        return true
    } else {
        return false
    }
}
function closeArtDialog(a) {
    if (top.art.dialog.list[a]) {
        top.art.dialog.list[a].close()
    }
}
function refreshArtDialog(a) {
    top.art.dialog.list[a].hide();
    top.art.dialog.list[a].show()
}
var _is_progress_loadding = 0;
function openProgressLoadding(e, d, f, a, b) {
    if (_is_progress_loadding == 0) {
        _is_progress_loadding = 1;
        var c = {
            id: "progressloadding",
            fixed: true,
            title: "读取数据",
            content: '<div class="tips-laryer-contbg"><div class="tips-txt"><div class="lodding-bar fl"><div class="lodding-bar-in" id="progress_bar" style=" width: 0%;"></div></div><div class="fl ml" id="progress_label" style="width:40px;">0%</div><div class="clear"></div><p>正在读取数据中......</p></div></div>',
            window: "top"
        };
        art.dialog(c);
        $("#progress_bar").css("width", a);
        $("#progress_label").html(a);
        setTimeout(function() {
            refreshProgressLoadding(e, d, f, b || 1500)
        },
        b || 1500)
    } else {
        _is_progress_loadding = 0
    }
}
function refreshProgressLoadding(c, b, d, a) {
    ajaxPost(c, b, 
    function(f) {
        var e = f.msg;
        if (typeof e == "string" && e.charAt(e.length - 1) == "%") {
            if ($("#progress_label").length > 0 && parseInt(e.substring(0, e.indexOf("%"))) > parseInt($("#progress_label").html().substring(0, $("#progress_label").html().indexOf("%")))) {
                $("#progress_bar").css("width", e);
                $("#progress_label").html(e)
            }
        } else {
            $("#progress_bar").css("width", "100%");
            $("#progress_label").html("100%");
            d(f);
            setTimeout(function() {
                closeProgressLoadding()
            },
            300)
        }
    },
    "json");
    if (_is_progress_loadding == 1) {
        setTimeout(function() {
            refreshProgressLoadding(c, b, d, a)
        },
        a)
    }
}
function closeProgressLoadding() {
    if (_is_progress_loadding == 1) {
        closeArtDialog("progressloadding");
        _is_progress_loadding = 0
    }
}
function loadCss(a) {
    if (document.createStyleSheet) {
        document.createStyleSheet(a)
    } else {
        $("head").append($('<link href="' + a + '" rel="stylesheet" type="text/css">)'))
    }
}
function showTipsInfo(g, e, a, b, d) {
    var c = "";
    var f = d || 1;
    c += '<div id="' + g + '"  class="' + (f == 1 || f == 3 ? "code-help-tip": "help-tip") + '">';
    c += '<img width="12" height="12" src="' + imagePath + 'icn_question.png" onclick="showTips(\'' + g + "', '" + e + "', '" + a + "', '" + b + "', " + f + ');">';
    c += "</div>";
    return c
}
function showTipsInfoInner(f, e, a, b, d) {
    var c = "";
    c += '<div style="display: none;" id="' + e + '" class="' + (d == 3 ? "help-tippop-rt": "help-tippop") + '">';
    c += '<div class="help-tiptxt">';
    c += '<i class="i-arrow"></i>';
    c += '<span class="closed"><a href="javascript:void(0);" onclick="showTips(\'' + f + "', '" + e + "', '" + a + "', '" + b + "', " + d + ');return false;"><img src="' + imagePath + 'close005.gif"></a></span>';
    c += "<h4>" + (formatMessage(a) == undefined || formatMessage(a) == null ? "帮助主题": formatMessage(a)) + "</h4>";
    c += "<span>" + (formatMessage(b) == undefined || formatMessage(b) == null ? "": formatMessage(b)) + "</span>";
    c += "</div>";
    c += '<iframe id="' + e + '_iframe" style="display:none;_display:block;position:absolute;top:5px;left:0px;z-index:-1;filter:mask(); width:260px;height:30px;"></iframe>';
    c += "</div>";
    return c
}
function showTips(e, d, a, b, c) {
    if ($("#" + d).length > 0) {
        $("#" + e).css("position", "");
        $("#" + d).remove()
    } else {
        $("#" + e).css("position", "relative");
        $("#" + e).css("z-index", "2");
        $("#" + e).append(showTipsInfoInner(e, d, a, b, c));
        $("#" + d).show();
        setTimeout(function() {
            $("#" + d + "_iframe").css("height", $("#" + d + " .help-tiptxt").height() + 30);
            $("#" + d + "_iframe").css("width", $("#" + d + " .help-tiptxt").width())
        },
        50)
    }
}
function checkUserRoleAndRsCount(a) {
    ajaxPost(ctx + "/json/generic/userRsCount", {},
    function(b) {
        if (b == null) {} else {
            if (b.error == "0") {
                if (b.msg.rscount >= auth.f_custom_rs_count) {
                    $("#poptips").html(RSCountInfo());
                    showPopTips()
                } else {
                    if (typeof(a) == "function") {
                        a.call(this)
                    }
                }
            }
        }
    })
}
var poptimes = 500;
var popheight = 60;
function hidePopTips() {
    $("#poptips").animate({
        bottom: "-=" + popheight
    },
    poptimes);
    $("#poptips_show").animate({
        bottom: "-=" + popheight
    },
    poptimes);
    setTimeout(function() {
        hideDIV("poptips");
        hideDIV("poptips_show")
    },
    poptimes + 100)
}
function showPopTips() {
    if ($("#poptips").is(":visible")) {
        return
    }
    $("#poptips").css("bottom", 0 - popheight);
    $("#poptips_show").css("bottom", 0 - popheight);
    showDIV("poptips");
    showDIV("poptips_show");
    $("#poptips").animate({
        bottom: "+=" + popheight
    },
    poptimes);
    $("#poptips_show").animate({
        bottom: "+=" + popheight
    },
    poptimes)
}
function closePopTipsHtml() {
    return '<span class="close"><a href="javascript:void(0);" onclick="hidePopTips();return;"><img src="' + imagePath + 'close005.gif" /></a></span>'
}
function TextPopTipsHtml(c, a) {
    var b = "";
    b += '<div class="pop-tips-txt">';
    b += '<div class="limitb">' + ((a != undefined && a != null && a != "") ? ('<img width="42" height="42" src="' + a + '">') : "") + "</div>";
    b += c;
    b += '&nbsp;<a href="' + ctx + '/payment" target=_blank class="btn-b">立即升级</a>';
    b += "</div>";
    return b
}
function showFullSamplePop() {
    $("#poptips").html(closePopTipsHtml() + TextPopTipsHtml("被访者数据回收已超过30条，做的很好！建议使用专业版进行全部数据的统计、分析、下载！"));
    showPopTips()
}
function showReportPop() {
    $("#poptips").html(closePopTipsHtml() + TextPopTipsHtml("被访者数据回收已超过30条，做的很好！建议使用专业版进行全部数据的统计、分析、下载！"));
    showPopTips()
}
function showExportWordPop() {
    normalPop()
}
function showDownloadPop() {
    showReportPop()
}
function showCrossPop() {
    showReportPop()
}
function showCrossDownloadPop() {
    showReportPop()
}
function showEntriesPop() {
    showReportPop()
}
function showLogicPop() {
    normalPop()
}
function showLogoPop() {
    normalPop()
}
function showMobilePop() {
    normalPop()
}
function showWordTypePop() {
    showEntPop()
}
function showAnalyzePop() {
    showReportPop()
}
function normalPop() {
    $("#poptips").html(closePopTipsHtml() + TextPopTipsHtml("无法使用该功能，请升级后使用"));
    showPopTips()
}
function showEntPop() {
    var a = "";
    a += '<div class="pop-tips-txt">';
    a += '<div class="limitb"></div>';
    a += (roleCode == "ts-public" ? "免费版": (roleCode == "ts-professional" ? "专业版": "")) + "用户无法使用当前功能，";
    a += '请升级至<span class="font20"><strong>企业版</strong></span>';
    a += '<span class="ml15"><a class="btn-b" target="_blank" href="' + ctx + '/enterprise-edition-try">申请试用企业版</a></span>';
    a += "</div>";
    $("#poptips").html(closePopTipsHtml() + a);
    showPopTips()
}
function showUpgradeTips() {
    $("#poptips").html('您是大众版用户，无法使用该功能，请升级后使用 <a href="' + ctx + '/version/upgrade" class="btn-b">立即升级</a>');
    showStandardPopTips(5000)
}
function RSCountInfo() {
    var a = "";
    a += closePopTipsHtml();
    a += formatMessage("poptips003", roleName, auth.f_custom_rs_count, (roleCode != "ts-public" ? '<a class="btn-b" href="' + ctx + '/services">查看定制服务</a>': '<a class="btn-b" href="' + ctx + '/version/upgrade">立即升级</a>'));
    return a
}
function gotoCreateRS() {
    window.location.href = ctx + "/survey/create"
}
function setSessionKey(b, a) {
    ajaxPost(ctx + "/json/generic/setSessionKey", {
        key: b
    },
    function(c) {
        if ($.isFunction(a)) {
            a.call(null, c)
        }
    })
}
var FloatLayerMap = {};
function addFloatLayer(d, a) {
    var c = FloatLayerMap[a];
    if (c == undefined || c == null) {
        c = {}
    }
    var b = 0;
    if (c.count != undefined) {
        b = c.count
    }
    if (c[d] == 1) {} else {
        c[d] = 1;
        c.count = b + 1;
        FloatLayerMap[a] = c
    }
}
function removeFloatLayer(d, a) {
    var c = FloatLayerMap[a];
    if (c == undefined || c == null) {
        return false
    }
    var b = 0;
    if (c.count != undefined) {
        b = c.count
    }
    if (c[d] == 1 && b >= 1) {
        c.count = b - 1;
        c[d] = null;
        FloatLayerMap[a] = c;
        if (c.count > 0) {
            return false
        } else {
            return true
        }
    } else {
        return false
    }
}
function showFloatLayer(c, a) {
    a = a != undefined ? a: "#overlay";
    if ($(a).is(":visible")) {} else {
        $(a).css("height", $(document).height()).show()
    }
    addFloatLayer(c, a);
    var b = $(c);
    repositionFloatLayer(b);
    b.bind("click", 
    function() {
        repositionFloatLayer(b)
    })
}
function repositionFloatLayer(f) {
    var d = $(window).width();
    var a = $(window).height();
    var b = parseInt(f.css("width").replace("px", ""));
    var e = parseInt(f.css("height").replace("px", ""));
    var c = (a - e) / 2;
    var h = (d - b) / 2;
    if ($.browser.msie && $.browser.version == "6.0") {
        var g = 0 - e / 2;
        var i = b / 2;
        f.css("position", "absolute").css("top", "50%").css("margin", g + "px 0 0 " + i + "px").show();
        $(window).scroll(function() {
            if (f.is(":visible")) {
                if (c < $(document).scrollTop()) {
                    f.offset({
                        top: $(document).scrollTop() + c
                    })
                } else {
                    if ($(document).scrollTop() == 0) {
                        f.offset({
                            top: c
                        })
                    } else {
                        f.offset({
                            top: $(document).scrollTop() + c
                        })
                    }
                }
            }
        })
    } else {
        f.css("top", c).css("left", h).show()
    }
}
function closeFloatLayer(b, a) {
    a = a != undefined ? a: "#overlay";
    if (removeFloatLayer(b, a)) {
        $(a).hide()
    }
    $(b).unbind("click").hide()
}
function switchFloatLayer(e, d, b) {
    b = b != undefined ? b: "#overlay";
    $(e).unbind("click").hide();
    var a = removeFloatLayer(e, b);
    addFloatLayer(d, b);
    var c = $(d);
    repositionFloatLayer(c);
    c.bind("click", 
    function() {
        repositionFloatLayer(c)
    })
}
function resetDockLayer(m, g, f, e) {
    var n = 0;
    if (f != undefined && f != null) {
        n = f
    }
    var l = 0;
    if (e != undefined && e != null) {
        l = e
    }
    var a = $(window).height();
    var c = $(document).scrollTop();
    var b = $(m);
    var i = $(g);
    var j = parseInt(b.css("height").replace("px", ""));
    var d = parseInt(i.css("height").replace("px", ""));
    var h = b.offset().top;
    var k = h - c + j;
    var o = 0;
    if (k > $(window).height()) {
        o = c + a - d + n
    } else {
        o = h + j - d + l
    }
    i.offset({
        top: o
    })
}
function showFloatDIV(f, c) {
    if (c.style == "dock") {
        var a = 0;
        if (c.fix1 != undefined && c.fix1 != null) {
            a = c.fix1
        }
        var e = 0;
        if (c.fix2 != undefined && c.fix2 != null) {
            e = c.fix2
        }
        var d = $(f).parent();
        var f = $(f);
        var b = c.where;
        if (b == undefined) {
            setInterval(function() {
                var m = $(window).height();
                var l = $(document).scrollTop();
                var h = parseInt(d.css("height").replace("px", ""));
                var j = parseInt(f.css("height").replace("px", ""));
                var g = d.offset().top;
                var k = g - l + h;
                var i = 0;
                if (k > $(window).height()) {
                    i = l + m - j + a
                } else {
                    i = g + h - j + e
                }
                f.offset({
                    top: i
                })
            },
            13)
        } else {
            if (b == "top") {
                setInterval(function() {
                    var i = $(document).scrollTop();
                    var g = d.offset().top;
                    var h = g + a;
                    if (g < i) {
                        h = i
                    }
                    f.offset({
                        top: h
                    })
                },
                13)
            }
        }
    }
}
function dybDialog(d) {
    var b = {
        id: "dybDialog" + new Date().getTime(),
        content: "提示信息",
        zIndex: 2012,
        okValue: "确定",
        cancelValue: "取消",
        ok: function() {},
        cancel: function() {}
    };
    if (d != null) {
        if (d.id != undefined && d.id != "") {
            b.id = d.id
        }
        if (d.content != undefined) {
            b.content = d.content
        }
        if (d.zIndex != undefined) {
            b.zIndex = d.zIndex
        }
        if (d.left != undefined) {
            b.left = d.left
        }
        if (d.okValue != undefined && d.okValue != "") {
            b.okValue = d.okValue
        }
        if (d.cancelValue != undefined && d.cancelValue != "") {
            b.cancelValue = d.cancelValue
        }
        if (d.lock != undefined && typeof(d.lock) == "boolean") {}
        if (d.ok != undefined && typeof(d.ok) == "function") {
            b.ok = d.ok
        }
        if (d.cancel != undefined && typeof(d.cancel) == "function") {
            b.cancel = d.cancel
        }
    }
    var a = $('<div id="' + b.id + '"></div>').hide().addClass("savedone").addClass("lightbox").css("width", "300px").css("z-index", b.zIndex);
    var c = "";
    c += '<div class="lbContent">';
    c += '<div class="fc-close"><a onclick="closeFloatLayer(\'#' + b.id + "');$('#" + b.id + '\').remove();return false;" title="关闭" href="javascript:void(0);"><img height="31" width="29" alt="关闭" src="' + imagePath + 'close.png"></a></div>';
    c += "<div>";
    c += '<div class="save-info"><div class="artDialog-txt ' + (b.left == 1 ? "t-left": "") + '"><p>' + b.content + "</p></div></div>";
    c += '<div class="artDialog-btn"> <a class="yellowbtn" id="save_dybDialog_' + b.id + '" href="javascript:void(0);">' + b.okValue + '</a>&nbsp;&nbsp;&nbsp;<a id="cancel_dybDialog_' + b.id + '" class="btn" href="javascript:void(0);">' + b.cancelValue + "</a></div>";
    c += "</div>";
    c += "</div>";
    a.append(c);
    setTimeout(function() {
        $("#save_dybDialog_" + b.id).bind("click", 
        function() {
            if (typeof(b.ok) == "function") {
                b.ok.call(this)
            }
            closeFloatLayer("#" + b.id);
            $("#" + b.id).remove()
        });
        $("#cancel_dybDialog_" + b.id).bind("click", 
        function() {
            if (typeof(b.cancel) == "function") {
                b.cancel.call(this)
            }
            closeFloatLayer("#" + b.id);
            $("#" + b.id).remove()
        })
    },
    500);
    $("#overlay").after(a);
    showFloatLayer("#" + b.id)
}
function showDialog(d, c, b) {
    var a = {
        id: d,
        width: c,
        fixed: true,
        window: "top",
        title: "",
        lock: true,
        padding: "10px 15px",
        content: b
    };
    art.dialog(a)
}
function showLargeDialog(b, a) {
    showDialog(b, 920, a)
}
function showMiddleDialog(b, a) {
    showDialog(b, 520, a)
}
function showSmallDialog(b, a) {
    showDialog(b, 300, a)
}
function refreshCss(g) {
    var f = document.getElementsByTagName("link");
    for (var d = 0, b = f.length; d < b; d++) {
        var e = f[d];
        if (e.id == g) {
            var a = e.rel;
            if (typeof a != "string" || a.length == 0 || a == "stylesheet") {
                var c = e.getAttribute("href").split("?")[0];
                setTimeout(function() {
                    e.setAttribute("href", c + "?t=" + Math.random())
                },
                200)
            }
        }
    }
}
function recordeTips(b, c, a) {
    ajaxPost(ctx + "/json/survey/recordeTips", {
        flag: b,
        tagid: c,
        sid: a
    },
    function(d) {})
}
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(b) {
        var a = this.length >>> 0;
        var c = Number(arguments[1]) || 0;
        c = (c < 0) ? Math.ceil(c) : Math.floor(c);
        if (c < 0) {
            c += a
        }
        for (; c < a; c++) {
            if (c in this && this[c] === b) {
                return c
            }
        }
        return - 1
    }
}
function getCssStyle(a) {
    for (var c = 0; c < document.styleSheets.length; c++) {
        var d;
        if (document.styleSheets[c].cssRules) {
            d = document.styleSheets[c].cssRules
        } else {
            d = document.styleSheets[c].rules
        }
        for (var b = 0; b < d.length; b++) {
            if (d[b].selectorText == a) {
                return d[b].style
            }
        }
    }
}
function isSupportFlash() {
    if (swfobject) {
        var b = swfobject.getFlashPlayerVersion();
        var a = b.major;
        if (a == 0) {
            return false
        } else {
            return true
        }
    } else {
        return false
    }
};